//package com.example.authservice.config;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.http.HttpMethod;
//import org.springframework.security.authentication.AuthenticationManager;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
//import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
//import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
//import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
//import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
//import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices;
//
//import javax.annotation.Resource;
//
///**
// * @author 鱼凫
// * @version 1.0
// * Create by 2023/4/16 18:40
// * @Description 授权服务器配置
// */
//@Configuration
//@EnableAuthorizationServer
//public class AuthorizationServer extends AuthorizationServerConfigurerAdapter {
//
//    @Resource(name="authorizationServerTokenServicesCustom")
//    private AuthorizationServerTokenServices authorizationServerTokenServices;
//
//    @Autowired
//    private AuthenticationManager authenticationManager;
////    @Bean
////    public AuthenticationManager authenticationManager(){
////        return new AuthenticationManager() {
////            @Override
////            public Authentication authenticate(Authentication authentication) throws AuthenticationException {
////                return null;
////            }
////        };
////
////    };
//
//    //客户端详情服务
//    @Override
//    public void configure(ClientDetailsServiceConfigurer clients)
//            throws Exception {
//        clients.inMemory()
//                .withClient("XcWebApp")
////                .secret("XcWebApp")
//                .secret(new BCryptPasswordEncoder().encode("XcWebApp"))
//                .resourceIds("hotel")
//                .authorizedGrantTypes("authorization_code", "password","client_credentials","implicit","refresh_token")// 该client允许的授权类型authorization_code,password,refresh_token,implicit,client_credentials
//                .scopes("all")
//                .autoApprove(false)
//                //客户端接收授权码的重定向地址
//                .redirectUris("http://www.51xuecheng.cn")
//        ;
//    }
//
//
//    //令牌端点的访问配置
//    @Override
//    public void configure(AuthorizationServerEndpointsConfigurer endpoints) {
//        endpoints
//                .authenticationManager(authenticationManager)
//                .tokenServices(authorizationServerTokenServices)
//                .allowedTokenEndpointRequestMethods(HttpMethod.POST);
//    }
//
//    //令牌端点的安全配置
//    @Override
//    public void configure(AuthorizationServerSecurityConfigurer security){
//        security
//                .tokenKeyAccess("permitAll()")
//                .checkTokenAccess("permitAll()")
//                .allowFormAuthenticationForClients()
//        ;
//    }
//}
